<?php include($folder.'/layouts/templates/backend/header.tpl') ?>
<?php $itemsPerPage = 4 ?>
<script type="text/javascript">
function setPreview(id) {
	$("#div_"+id).css("background-color", 'rgb('+
		$("#textbox_"+id+"_red").val() + ', ' +
		$("#textbox_"+id+"_green").val() + ', ' +
		$("#textbox_"+id+"_blue").val() + ')')
}
$(function() {
	tableData =
		{
<?php echo repeater(array(
	'id' => 'main',
	'selectMethod' => 'szinek_select',
	'parameters' => array(
		empty($_POST['main']['sortColumn'])?'\'name\'':'\''.$_POST['main']['sortColumn'].'\'',
		empty($_POST['main']['sortDirection'])?'\'asc\'':'\''.$_POST['main']['sortDirection'].'\''),
	'separatorStringLength' => 1,
	'cellTemplate' => '
		\'{id}\':
				{
					\'red\':{red},
					\'green\':{green},
					\'blue\':{blue}
				},',
	'itemsPerPage' => $itemsPerPage)) ?>
		}
	for (subject in tableData)
	{
		for (color in tableData[subject])
		{
			$("#slider_"+subject+"_"+color).slider({
				value: tableData[subject][color],
				min: 0,
				max: 255,
				step: 1,
				orientation: 'horizontal',
				change: function(event, ui) {
					senderIDSplit = event.target.id.split("_")
					$("#textbox_"+senderIDSplit[1]+"_"+senderIDSplit[2]).val(ui.value)
					setPreview(senderIDSplit[1])
				}
			})
			$("#textbox_"+subject+"_"+color).change(function(event) {
				senderIDSplit = event.target.id.split("_")
				$("#slider_"+senderIDSplit[1]+"_"+senderIDSplit[2]).slider('option', 'value',
					$("#textbox_"+senderIDSplit[1]+"_"+senderIDSplit[2]).val())
				setPreview(senderIDSplit[1])
			})
		}
	}
})
</script>
<?php
$master['action'] = 'color_update';
$master['attributes'] = null;
$master['pageTitle'] = 'Színek';
$master['toolbarItems'] = array(
	'<input type="submit" class="button" value="Mentés" />',
	'<input type="submit" class="button" name="submitaction_color_default_update" onclick="javascript:return confirm(\'Biztos, hogy vissza szeretnéd állítani az eredeti (barna árnyalatú) színeket?\')" value="Alapértelmezett értékek visszaállítása" />',
	'<input type="button" value="Vissza" class="button" onclick="javascript:window.location.href=\''.$prefix.'/adminisztracio\'" />'
);
?>
<?php include($folder.'/layouts/templates/backend/middle.tpl') ?>
<?php if (!empty($_SESSION['id'])): ?>
<?php echo extendedTable(array(
	'header' => paginator(array(
		'subId' => 'paginator1',
		'selectCountMethod' => 'szinek_select_count',
		'itemsPerPageAll' => array(4, 8, 16, 32),
		'itemsPerPage' => $itemsPerPage,
		'id' => 'main')),
	'body' => table(array(
		'sortColumn' => 'name',
		'sortDirection' => 'asc',
		'selectMethod' => 'szinek_select',
		'itemsPerPage' => $itemsPerPage,
		'columns' => array(
			array('title'=>'név', 'template'=>'{name}', 'width'=>'110px', 'align'=>'left', 'sortColumn'=>'name'),
			array('title'=>'csúszka', 'template'=>'
				<table cellpadding="0" cellspacing="0" style="width:100%">
					<tr>
						<td style="padding:7px;font-size:x-small">
							<div id="slider_{id}_red"></div>
						</td>
					</tr>
					<tr>
						<td style="padding:7px;font-size:x-small">
							<div id="slider_{id}_green"></div>
						</td>
					</tr>
					<tr>
						<td style="padding:7px;font-size:x-small">
							<div id="slider_{id}_blue"></div>
						</td>
					</tr>
				</table>', 'width'=>'300px', 'align'=>'left', 'sortColumn'=>null),
			array('title'=>'érték',
				'template'=>'
				<table>
					<tr>
						<td>
							<input type="text" id="textbox_{id}_red" name="colors[{id}][red]" value="{red}" />
						</td>
					</tr>
					<tr>
						<td>
							<input type="text" id="textbox_{id}_green" name="colors[{id}][green]" value="{green}" />
						</td>
					</tr>
					<tr>
						<td>
							<input type="text" id="textbox_{id}_blue" name="colors[{id}][blue]" value="{blue}" />
						</td>
					</tr>
				</table>',
				'width'=>'150px', 'align'=>'center', 'sortColumn'=>''),
			array('title'=>'minta', 'template'=>'
				<div id="div_{id}" style="background-color:rgb({red},{green},{blue});height:50px">&nbsp;</div>',
				'sortColumn'=>null, 'width'=>'60px',
				'align'=>'center')
		),
		'id' => 'main')),
	'footer' => paginator(array(
		'subId' => 'paginator2',
		'isFirst' => false,
		'selectCountMethod' => 'szinek_select_count',
		'itemsPerPageAll' => array(4, 8, 16, 32),
		'itemsPerPage' => $itemsPerPage,
		'id' => 'main')))) ?>
		<br />
		<span style="font-style:italic">
A színösszetevőknél 0 és 255 közötti értékeket kell megadni.
		</span>
<?php endif; ?>
<?php include($folder.'/layouts/templates/backend/footer.tpl') ?>